home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / mus / misc / maplay1_2.lha / maplay / header.h < prev    next >
C/C++ Source or Header  |  1994-06-23  |  3KB  |  83 lines

  1. /*
  2.  *  @(#) header.h 1.7, last edit: 6/15/94 16:55:33
  3.  *  @(#) Copyright (C) 1993, 1994 Tobias Bading (bading@cs.tu-berlin.de)
  4.  *  @(#) Berlin University of Technology
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 2 of the License, or
  9.  *  (at your option) any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  */
  20.  
  21. #ifndef HEADER_H
  22. #define HEADER_H
  23.  
  24. #include "all.h"
  25. #include "ibitstream.h"
  26. #include "crc.h"
  27.  
  28.  
  29. enum e_mode { stereo, joint_stereo, dual_channel, single_channel  };
  30. enum e_sample_frequency { fourtyfour_point_one, fourtyeight, thirtytwo };
  31.  
  32.  
  33. // Class for extraction information from a frame header:
  34. class Header
  35. {
  36.   static const uint32    frequencies[3];
  37.   uint32        h_layer, h_protection_bit, h_bitrate_index,
  38.              h_padding_bit, h_mode_extension;
  39.   e_mode        h_mode;
  40.   e_sample_frequency    h_sample_frequency;
  41.   uint32        h_number_of_subbands, h_intensity_stereo_bound;
  42.   bool            h_copyright, h_original;
  43.   Crc16            *crc;
  44.   uint16        checksum;
  45.  
  46.   uint32        calculate_framesize ();
  47.  
  48. public:
  49.             Header (void) { crc = (Crc16 *)0; }
  50.                ~Header (void) { if (crc) delete crc; }
  51.   bool            read_header (Ibitstream *, Crc16 **);
  52.             // read a 32-bit header from the bitstream
  53.  
  54.   // functions to query header contents:
  55.   uint32        layer (void) { return h_layer; };
  56.   uint32        bitrate_index (void) { return h_bitrate_index; };
  57.   e_sample_frequency    sample_frequency (void) { return h_sample_frequency; };
  58.   uint32        frequency (void) { return frequencies[h_sample_frequency]; }
  59.   static uint32    frequency (e_sample_frequency rate) { return frequencies[rate]; }
  60.   e_mode        mode (void) { return h_mode; };
  61.   bool            checksums (void) { return !h_protection_bit; }
  62.   bool            copyright (void) { return h_copyright; }
  63.   bool            original (void) { return h_original; }
  64.  
  65.   bool            checksum_ok (void) { return checksum == crc->checksum (); }
  66.             // compares computed checksum with stream checksum
  67.  
  68.   // functions which return header informations as strings:
  69.   const char *        layer_string (void);
  70.   const char *        bitrate_string (void);
  71.   const char *        sample_frequency_string (void);
  72.   const char *        mode_string (void);
  73.  
  74.   uint32        number_of_subbands (void) { return h_number_of_subbands; };
  75.             // returns the number of subbands in the current frame
  76.   uint32        intensity_stereo_bound (void) {return h_intensity_stereo_bound; };
  77.             // (Layer II joint stereo only)
  78.             // returns the number of subbands which are in stereo mode,
  79.             // subbands above that limit are in intensity stereo mode
  80. };
  81.  
  82. #endif
  83.